from flask import session, g


def session_authentication():
    """根据session将用户身份认证信息写入g对象"""
    if session.get('is_login'):
        g.username = session.get('username')
    else:
        g.username = 'anonymous'
